package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 * @Author: wenjingyuan
 * @Date: 2023/05/29/17:57
 * @Description:
 */
public class InputStreamDemo1 {
    public static void main(String[] args) {
        //1.创建流对象
        InputStream inputStream=null;
        try {
            inputStream=new FileInputStream("b.txt");
            //2.读写操作
            while(true){
                int c=inputStream.read();
                if(c==-1) break;
                System.out.printf("%c",c);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            //3.关闭流
            try {
                inputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }


    }
}
